<template>
	<view class="content">
		<button type="primary" @click="handleLocation">获取位置</button>
		<button type="primary" @click="handleChoose">打开地图选择位置</button>
		
		<button type="primary" @click="handleOpenLocation">打开地图查看位置</button>
		<button type="primary" @click="handleOpenMap">打开地图</button>
	</view>
</template>

<script setup>
	import {
		onLoad
	} from '@dcloudio/uni-app';
	onLoad((options) => {
		if(options.cinemas){
			console.log(JSON.parse(decodeURIComponent(options.cinemas))); 
		}
	})
	function handleLocation(){
		console.log("getLocation");
		uni.getLocation({
			success(res){
				console.log("latitude",res.latitude);
				console.log("longitude",res.longitude);
			},
			fail(res){
				console.log('fail',res);
			}
		})
	}
	function handleChoose(){
		uni.getLocation({
			success(res){
				console.log("latitude",res.latitude);
				console.log("longitude",res.longitude);
				uni.chooseLocation({
					latitude:res.latitude,
					longitude:res.longitude,
					success(res){
						console.log("res",res);
					}
				})
			}
		})
		
	}
	function handleOpenLocation(){
		uni.getLocation({
			success(res){
				console.log("latitude",res.latitude);
				console.log("longitude",res.longitude);
				uni.openLocation({
					latitude:res.latitude,
					longitude:res.longitude,
					success(res){
						console.log("res",res);
					}
				})
			}
		})
	}
	function handleOpenMap(){
		uni.redirectTo({
			url:'/pages/map-page/map-page'
		})
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	.content button{
		width: 90% !important;
	}
</style>
